package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.dg11185.nearshop.net.entity.Photo;

public class GetMerchantPhotoListResponse {

    public NetStatus status = null;

    public String total;

    public List<Photo> photos = null;

    public GetMerchantPhotoListResponse() {
        photos = new ArrayList<Photo>();
    }

    public void parseJson(String response) {
        try {
            JSONObject jsonObject = new JSONObject(response);
            total = jsonObject.optString("total");
            status = NetStatus.getStatus(jsonObject.optString("status"));

            if (!jsonObject.isNull("photoList")) {
                JSONArray photoArray = jsonObject.optJSONArray("photoList");

                for (int a = 0; a < photoArray.length(); a++) {
                    Photo photo = new Photo();
                    photo.parseEntity(photoArray.getJSONObject(a));
                    photos.add(photo);
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
